<template>
    <div class="flow-box">
        <div class="flow-charts">
            <div class="flow-charts-single" :class="{'disabled-flow-charts-single':item.isDisabled, 'current-active':currentStep === item.id }"
                v-for="(item) in data" :key="item.id" @click="goToStep(item.id)">
                <el-icon v-if="item.isDisabled" size="20">
                    <SuccessFilled />
                </el-icon>
                <div style="margin-left: 12px">
                    <div class="name">{{ item.name }}审批</div>
                    <span style="font-size: 12px;" v-if="item.isDisabled">(完成审批)</span>
                </div>
            </div>
        </div>
        <div style="width: 80%;margin: 0 auto;">
            <button>上一步</button>
            <button>下一步</button>
        </div>
    </div>

</template>

<script setup lang="ts">
import { ref, reactive } from 'vue'

// 节点状态默认为0 通过为1 驳回为2 
// 当前步骤
const currentStep = ref(3)

const data = reactive([
    {   
        id: 1,
        name: '部门主管',
        count: 100,
        isDisabled: true
    },
    {
        id: 2,
        name: '部门经理',
        count: 100,
        isDisabled: true
    },
    {   
        id: 3,
        name: '总经理',
        count: 100,
        isDisabled: false
    },
    {
        id: 4,
        name: '董事长',
        count: 100,
        isDisabled:false
    }])

const goToStep = (id?: number) => {
    console.log(id)
}
</script>
<script lang="ts">
    export default {
        name: "Flow"
    }
</script>

<style scoped lang="scss">
.flow-charts{
    width: 80%;
    margin: 28px auto;
    display: flex;
    justify-content: center;
    .flow-charts-single{
        flex: 1;
        height: 40px;
        background: $base-flow-background;
        position: relative;
        display: inline-block;
        margin-right: 34px;
        text-align: center;
        display: flex;
        // flex-direction: column;
        align-items: center;
        justify-content: center;
        border-bottom-right-radius: 2px;
        border-top-right-radius: 2px;
        //悬浮颜色
        .name{
            font-size: 12px;
            color: #fff;
            line-height: 18px;
            // margin-top: 5px;
            font-weight: 400;
        }
        .number{
            font-size: 16px;
            font-family: PingFangSC-Semibold, PingFang SC;
            font-weight: 600;
            color: #FFFFFF;
            line-height: 16px;
        }
        &::after{
            content:'';
            border-bottom: 20px solid transparent;
            border-left: 26px solid $base-flow-background;
            border-top: 20px solid transparent;
            // display: inline-block;
            position: absolute;
            right: -25px;
            top: 0;
        }
        &::before{
            content:'';
            border-bottom: 20px solid $base-flow-background;
            border-left: 26px solid transparent;
            border-top: 20px solid $base-flow-background;
            // display: inline-block;
            position: absolute;
            left: -25px;
            top: 0;
        }
        &:first-child{
            border-top-left-radius: 4px;
            border-bottom-left-radius: 4px;
            
            &::before{
                display: none;
            }
        }
        &:last-child{
            margin-right: 0;
            border-top-right-radius: 4px;
            border-bottom-right-radius: 4px;
            
            &::after{
                display: none;
            }
        }
    }
    .flow-charts-single:hover{
        cursor: pointer;
        background: $base-hover-background;
        .name{
            color: #fff;
        }
        &::after{
            border-bottom: 20px solid transparent;
            border-left: 26px solid $base-hover-background;
            border-top: 20px solid transparent;
        }
        &::before{
            border-bottom: 20px solid $base-hover-background;
            border-left: 26px solid transparent;
            border-top: 20px solid $base-hover-background;
        }
    }
    .current-active{
        cursor: pointer;
        background: $base-current-background;
        .name{
            color: #fff;
        }
        &::after{
            border-bottom: 20px solid transparent;
            border-left: 26px solid $base-current-background;
            border-top: 20px solid transparent;
        }
        &::before{
            border-bottom: 20px solid $base-current-background;
            border-left: 26px solid transparent;
            border-top: 20px solid $base-current-background;
        }
    }
    .disabled-flow-charts-single{
        background:$base-active-background;
        .name{
            color: rgb(255, 255, 255);
        }
        &::after{
            border-bottom: 20px solid transparent;
            border-left: 26px solid $base-active-background;
            border-top: 20px solid transparent;
        }
        &::before{
            border-bottom: 20px solid $base-active-background;
            border-left: 26px solid transparent;
            border-top: 20px solid $base-active-background;
        }
    }
}
</style>